package masterjava.client.gxt.highcharts;

import com.extjs.gxt.ui.client.widget.Component;
import com.extjs.gxt.ui.client.widget.TabItem;
import masterjava.client.GxtTestEntryPoint;
import masterjava.common.client.gxt.base.tabs.BaseTabs;

import java.util.Iterator;

/**
 * User: gkislin
 * Date: 7/20/11
 */
public class HighChartsEntryPoint extends GxtTestEntryPoint {
    @Override
    protected Component getContent() {
        return new BaseTabs<Integer>(
                new Iterable<Integer>() {
                    @Override
                    public Iterator<Integer> iterator() {
                        return new Iterator<Integer>() {
                            int i = 0;

                            @Override
                            public boolean hasNext() {
                                return i <= 0;//HighchartsFactory.TYPES.length;
                            }

                            @Override
                            public Integer next() {
                                i++;
                                return i - 1;
                            }

                            @Override
                            public void remove() {
                            }
                        };
                    }
                }
        ) {
            @Override
            protected TabItem createTabItem(Integer next) {
                TabItem chartTab = new TabItem();
                if (next == HighchartsFactory.TYPES.length) {
                    chartTab.setText("rawChart");
                    chartTab.add(HighchartsFactory.getRawChart());
                } else {
                    chartTab.setText(HighchartsFactory.TYPES[next]);
                    chartTab.add(HighchartsFactory.getChart(next));
                }
                return chartTab;
            }
        };
    }
}
